<%@ page import="com.xiaolin.dao.impl.UserDAOImpl" %>
<%@ page import="com.xiaolin.bean.User" %>
<%@ page import="com.xiaolin.utils.dbUtils" %>
<%@ page import="java.sql.Connection" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/1/5
  Time: 18:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    int id = Integer.parseInt(request.getParameter("id"));
    if (id == 1) {
        String acNum = request.getParameter("acNum");
        String name = request.getParameter("name");
        int age = Integer.parseInt(request.getParameter("age"));
        String email = request.getParameter("email");
        String phone = request.getParameter("phone");
        UserDAOImpl udi = new UserDAOImpl();
        Connection conn = dbUtils.getConnection();
        User user = udi.getUserByAcNum(conn, acNum);
        user.setName(name);
        user.setAge(age);
        user.setEmail(email);
        user.setPhone(phone);
        udi.updateByAcNum(conn, user);
        out.print("<h1>修改成功！</h1>");
        response.setHeader("refresh", "1;url='viewPerIn.jsp?id=2&acNum=" + user.getAcNum() + "'");
    } else if (id == 2) {
        String email = request.getParameter("email");
        String passWord = request.getParameter("pw2");
        UserDAOImpl udi = new UserDAOImpl();
        Connection conn = dbUtils.getConnection();
        User user = udi.getUserByEmail(conn, email);
        user.setPassWord(passWord);
        udi.update(conn, user);
        out.print("<h1>修改成功！</h1>");
        response.setHeader("refresh", "1;url='viewPerIn.jsp?id=3&acNum=" + user.getAcNum() + "'");
    } else if (id == 3) {
        String acNum = request.getParameter("acNum");
        Connection conn = dbUtils.getConnection();
        UserDAOImpl uD = new UserDAOImpl();
//        out.print(acNum);
        uD.deleteByAcNum(conn, acNum);
%>
<script type="text/javascript" src="script/jquery-1.7.2.js"></script>
<script type="text/javascript">
    $(function () {
        $("#bu1").click(function () {
            window.top.location.href="../index.jsp";
        })
    })
</script>
<h1>注销成功！</h1>
<button id="bu1" value="确定" type="button">确定</button>
<%
    }
%>
</body>
</html>
